<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('正式服务商列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <input name="agentNature" type="hidden" value="1">
                        <ul>
                            <li>
                                <label style="width:80px;">服务商编号：</label>
                                <input type="text" name="agentNum"/>
                            </li>
                            <li>
                                <label style="width:80px;">服务商名称：</label>
                                <input type="text" name="agentName"/>
                            </li>
                            <li>
                                <label style="width:80px;">法人身份证：</label>
                                <input type="text" name="identityNum"/>
                            </li>
                            <li>
                                <label style="width:80px;">登录账号：</label>
                                <input type="text" name="loginName"/>
                            </li>
                            <li>
                                <label style="width:80px;">服务商状态：</label>
                                <select name="agentStatus">
                                    <option value="0">正常</option>
                                    <option value="5">服务商注销</option>
                                    <option value="6">已禁用</option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label style="width:80px;">创建日期：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始日期" name="params[beginAddTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束日期" name="params[endAddTime]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"  class="table text-nowrap"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var datas = [[${@dict.getType('agent_status')}]];
        var editFlag = [[${@permission.hasPermi('agentInfo:agentInfo:edit')}]];
        var prefix = ctx + "agentInfo/agentInfo";

        $(function() {
            var options = {
                url: prefix + "/list3",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                sortName:"localdate",
                sortOrder:"desc",
                modalName: "服务商申请",
                columns: [
                {
                    field: 'agentNature',
                    title: '数据来源',
                    visible: false
                },
                {
                    field: 'agentNum',
                    title: '服务商编号'
                },
                {
                    field: 'agentName',
                    title: '服务商名称'
                },
                    {
                        field: 'smName',
                        title: '销售经理'
                    },
                    {
                        field: 'smName1',
                        title: '签约经理'
                    },
                {
                    field: 'areaName',
                    title: '区域',
                    formatter:function (value, row, index) {
                        return $.table.tooltip(value,5);
                    }
                },
                {
                    field: 'commissary',
                    title: '法人姓名'
                },
                {
                    field: 'showIdentitynum',
                    title: '身份证'
                },
                {
                    field: 'linkPhone',
                    title: '联系电话'
                },
                {
                    field: 'agentStatus',
                    title: '状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(datas, value);
                    }
                },
                {
                    field: 'grade',
                    title: '档位'
                },
                {
                    field: 'supportLevel',
                    title: '扶持档位'
                },
                {
                    field: 'supportDate',
                    title: '到期时间'
                },
                {
                    field: 'norm_num',
                    title: '剩余指标'
                },
                {
                    field: 'loginName',
                    title: '登录账号'
                },
                {
                    field: 'smName',
                    title: '销售经理',
                    formatter:function (value, row, index) {
                        return $.table.tooltip(value,5);
                    }
                },
                {
                    field: 'beginValid',
                    title: '有效期(起始)',
                    formatter:function (value, row, index) {
                        return $.table.tooltip(value,10);
                    }
                },
                {
                    field: 'endValid',
                    title: '有效期(截止)',
                    formatter:function (value, row, index) {
                        return $.table.tooltip(value,10);
                    }
                },
                {
                    field: 'addName',
                    title: '添加人',
                    formatter:function (value, row, index) {
                        return $.table.tooltip(value,5);
                    }
                },
                {
                    field: 'localdate',
                    title: '添加日期',
                    formatter:function (value, row, index) {
                        return $.table.tooltip(value,10);
                    }
                },
                {
                    field: 'note',
                    title: '备注',
                    formatter:function (value, row, index) {
                        return $.table.tooltip(value,5);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="query(\'' + row.agentNum + '\')"><i class="fa fa-edit"></i>查看盟主</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function changeStatus() {
            var agentNum = $.table.selectColumns("agentNum");
            $.modal.open("启用/禁用服务商",prefix + "/changeStatus/" + agentNum,'800');
        }
        function cancelAgent() {
            var agentNum = $.table.selectColumns("agentNum");
            $.modal.open("注销服务商",prefix + "/cancelAgent/" + agentNum,'800');
        }
        /* 用户管理-重置密码 */
        function resetPwd() {
            var agentNum = $.table.selectColumns("agentNum");
            $.modal.open("重置密码", prefix + '/resetPwd/' + agentNum, '800', '300');
        }
        function setLeader() {
            var agentNature = $.table.selectColumns("agentNature");
            /*if (0!=agentNature){
                $.modal.msgError("数据来源非APP");
                return;
            }*/
            var agentNum = $.table.selectColumns("agentNum");
            $.modal.open("申请盟主", prefix + '/setLeader/' + agentNum, '1200');
        }
/*
        function query(agentNum) {
            $.modal.open("查看盟主",prefix + "/findInfo?agentNum=" + agentNum,1200,800);
        }*/

        function query(agentNum) {
            //如果是移动端，就使用自适应大小弹窗
            var width=1200;
            var height=$(window).height() - 50;
            if ($.common.isMobile()) {
                width = 'auto';
                height = 'auto';
            }
            var url = prefix + "/findInfo?agentNum=" + agentNum;
            var btn = ['关闭'];
            var options = {
                title: '查看盟主',
                width: width,
                height: height,
                url: url,
                btn: btn,
                yes:function(index){
                    layer.close(index);
                }
            };
            $.modal.openOptions(options);
        }

    </script>
</body>
</html>